package com.ikun.controller;

import com.aliyuncs.exceptions.ClientException;
import com.ikun.pojo.Result;
import com.ikun.utils.UploadUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class UploadController {
    @Autowired
    UploadUtil uploadUtil;
    //文件上传
    @PostMapping("/upload")
    public Result uploadFile(@RequestParam MultipartFile image) throws ClientException {
        System.out.println("接收到上传的请求");
        String resultUrl=uploadUtil.uploadFile(image);
        System.out.println("上传成功，路径为: "+resultUrl);
        return Result.success(resultUrl);
    }
}
